home *** CD-ROM | disk | FTP | other *** search
/ A.C.E. 2 / ACE CD 2.iso / FILES / DOCS / AMOSDOC.LHA / AmosHyperBook.dms / in.adf / Manual / ALLIANCE-21 / ALLIANCE-21
Encoding:
Text File  |  1992-03-20  |  5.0 KB  |  134 lines

  1.  
  2.  
  3.                          21: SCREEN COMPACTION                             276
  4.                       ---------------------------
  5.  
  6.  
  7.                        SPACK (screen compaction)
  8.  
  9. SPACK s TO n [tx,ty,bx,by]
  10.  
  11. The SPACK command packs screen s into memory bank n. Everything about
  12. the current image is saved, including its mode, screen size, offset and
  13. display position. This allows you to recreate your screen in exactly
  14. its original state.
  15.  
  16.   s is the number of the screen which contains yur image. n holds the
  17. number of a memory bank from 1-16. If this bank doesn't currently
  18. exist, it will be reserved for you automatically. Your new bank will be
  19. stored in FAST memory if it's available, and will be saved along with
  20. our Basic program. After you've called this function, the size of your
  21. screen can be found using LENGTH. Example:
  22.  
  23.         F$=FSEL$("*","","Load a picture")
  24.         Load Iff F$,0
  25.         Spack 0 To 1
  26.         Print "The length of your new bank is ";Length(1);" Bytes"
  27.         Wait Key
  28.         Screen Close 0
  29.         UnPack 1 To 0 : Rem recreate compacted screen
  30.  
  31. You don't, of course have to compact an entire screen with this
  32. instruction. The optional parameters let you compress any rectangular
  33. section of the display you like.
  34.  
  35.   tx,ty now hold the coordinates of the top left corner of this region.
  36. bx,by set the position of the bottom right corner. All x coordinates
  37. are rounded to the nearest 8 pixel boundary.
  38.  
  39.   Note that in order to achieve the maximum memory reduction, SPACK
  40. will attempt to compact your image using several different strategies.
  41. It will then compress your image using the method which consumes the
  42. least amount of memory. One side effect of this efficiency, is that it
  43. usually takes around 6 secs to compress one of your images. This is        277
  44. hardly a disadvantage however, as normally the compaction is only
  45. required when you are writing your programs.
  46.  
  47.   Since each image can be unpacked on the screen in less than a second,
  48. there's no risk of interference with the speed of your games. It speeds
  49. is of the essence though, you may wish to use the CBLOCK system
  50. instead. See the section on Background Graphics for more details.
  51.  
  52.   Incidentally, if you compare the compacted size of your files with
  53. their original length on the disc, you may be mislead into
  54. underestimating the size of the memory reduction. It's important to
  55. realize that the vast majority of these files have ALREADY BEEN
  56. COMPESSED using the standard IFF compaction routines. So it's rather
  57. surprising that AMOS can reduce them by a further 20 % !
  58.  
  59.   Compacted screens are perfect for the titles and hi-score tables
  60. required in an arcade game, as they allow you to introduce snazzy
  61. screen effects without consuming enormous quantities of memory. They
  62. can also be incorporated directly into RPGs and Adventures.
  63.  
  64.  
  65.  
  66.                          PACK (pack a screen)
  67.  
  68. PACK s TO n [tx,ty,bx,by]
  69.  
  70. Compresses screen s into bank number n. Unlike the previous SPACK
  71. command, only the image data is compressed. So your compacted screen
  72. must always be unpacked directly into an existing screen.
  73.  
  74.   Because of the way images are decompressed, there will be a
  75. noticeable shimmer effect unless you've previously double buffered your
  76. screens. Try to avoid using PACK with single buffered screens. It's
  77. much more sensible to call the SPACK system for this purpose.
  78.  
  79.   If the optional coordinates are included, only a section of the image
  80. will be compressed.
  81.  
  82.   Since PACK is fully compatible with the standard AUTOBACK system,
  83. it's easy to combine compacted images with moving screens. If you are
  84. using Autoback 2  mode, you'll even be able to unpack your images
  85. BEHIND existing bobs. It's therefore possible to exploit this
  86. instruction in conjunction with SCREEN OFFSET to create fantastic
  87. scrolling backgrounds for your games.
  88.  
  89.  
  90.  
  91.                   UNPACK (unpack a compacted screen)
  92.  
  93. Decompresses a screen which has been previously compacted using the
  94. SPACK or PACK instructions. Each compaction routine has its own
  95. specifix form of the UNPACK command.
  96.  
  97.  SPACK
  98.  -----
  99.  
  100. UNPACK b TO s
  101.  
  102. Opens a screen s and restores the compacted screen into bank b. If this
  103. screen already exists, it will completely replaced by the new image.
  104. Once the screen has been unpacked, it will be neatly flicked into view.    278
  105.  
  106.  PACK
  107.  ----
  108.  
  109. PACKed screens can be unpacked using two separate instructions. These
  110. take an image from a memory bank, and load it straight into an existing
  111. screen. WARNING! The destination screen MUST be in exactly the same
  112. format as your compacted picture, otherwise you'll get an
  113. "illegal function call" error.
  114.  
  115.   When you unpack your screens, you may notice that the effect is
  116. slightly messy. That's 'cause the PACK command is only really intended
  117. for use with the double buffering system. Providing your screen is
  118. double buffered, you'll get a delightfully smooth result.
  119.  
  120. UNPACK b
  121.  
  122. Unpacks the screen at its original position
  123.  
  124. UNPACK b,x,y
  125.  
  126. Redraws your image starting at coordinates x,y. If the new image
  127. doesnt' fit into the current screen, you'll get an error message.
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.